#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],top,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++top]=48+x%10;while(top) pc(stk[top--]);}
}
using namespace IO;
const int N = 100,M = 1e6+10;
int n,c[N],t[N],w[N],m,f[M],f1[M],o,ans;
signed main()
{
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	read(n);
	for(int i = 1;i <= n;i++) read(c[i]);
	for(int i = 1;i <= n;i++) read(t[i]);
	for(int i = 1;i <= n;i++) read(w[i]);
	read(m);
	if(m <= 1e6)
	{
		for(int i = 1;i <= n;i++)
		{
			o = 1;
			while(o <= c[i])
			{
				c[i] -= o;
				for(int j = m;j >= t[i]*o;j--)
					f[j] = max(f[j],f[j-t[i]*o]+w[i]*o); 
				o *= 2;
			}
			if(c[i])
			{
				o = c[i];
				for(int j = m;j >= t[i]*o;j--)
					f[j] = max(f[j],f[j-t[i]*o]+w[i]*o); 
			}
		}
		for(int i = 1;i <= m;i++) ans = max(ans,f[i]);
		print(ans); flush();
		return 0;
	}
	return 0;
}



